Skip to content

fix(catalog): preserve metadata location when using snapshots=refs#4724

Open
ArnavBalyan wants to merge 1 commit into
apache:mainfrom
ArnavBalyan:arnavb/fix-metadata-loc
Open

fix(catalog): preserve metadata location when using snapshots=refs#4724
ArnavBalyan wants to merge 1 commit into
apache:mainfrom
ArnavBalyan:arnavb/fix-metadata-loc

Conversation

@ArnavBalyan

Copy link
Copy Markdown
Member
  • Loading table with snapshots=refs returned a null metadata location, while snapshots=all returned it correctly.
  • The refs filter removes historical snapshots, which marks the metadata as having pending changes and clears its metadata location pointer.
  • Re stamp the original location onto the filtered metadata so both modes return the same pointer.
  • Fixes Metadata-location is always absent in LoadTableResult when using ?snapshots=refs #4656

Checklist

  • 🛡️ Don't disclose security issues! (contact security@apache.org)
  • 🔗 Clearly explained why the changes are needed, or linked related issues: Fixes #
  • 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
  • 💡 Added comments for complex logic
  • 🧾 Updated CHANGELOG.md (if needed)
  • 📚 Updated documentation in site/content/in-dev/unreleased (if needed)

Copilot AI review requested due to automatic review settings June 12, 2026 07:27
@github-project-automation github-project-automation Bot moved this to PRs In Progress in Basic Kanban Board Jun 12, 2026
@ArnavBalyan

Copy link
Copy Markdown
Member Author

cc @jbonofre @dimas-b could you pls TAL thanks! :)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes loss of metadata-location in Iceberg REST LoadTableResponse when filtering snapshots to refs, and adds a regression test to ensure the location is preserved.

Changes:

  • Preserve metadata-location when returning a filtered snapshots=refs response.
  • Expose filterResponseToSnapshots for testing via @VisibleForTesting.
  • Add a new test that validates snapshot filtering keeps the original metadata location.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java Rebuilds filtered metadata while preserving metadata location; makes the helper accessible for tests.
runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandlerTest.java Adds regression coverage ensuring metadata-location is retained after filtering to refs.

Comment on lines +1403 to 1405
@VisibleForTesting
@NonNull LoadTableResponse filterResponseToSnapshots(
LoadTableResponse loadTableResponse, String snapshots) {
Comment on lines +1419 to +1423
TableMetadata filteredMetadataWithLocation =
TableMetadata.buildFrom(filteredMetadata)
.withMetadataLocation(metadata.metadataFileLocation())
.discardChanges()
.build();
Comment on lines +309 to +310
@SuppressWarnings("resource")
void filterResponseToSnapshotsRefsPreservesMetadataLocation() throws Exception {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Metadata-location is always absent in LoadTableResult when using ?snapshots=refs

2 participants